package com.atguigu.acyjl.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;


import com.atguigu.acyjl.Catalog;
import com.atguigu.acyjl.Market;
import com.atguigu.acyjl.PlaySounds;
import com.atguigu.acyjl.R;
import com.atguigu.acyjl.policy.Policy;
import com.atguigu.acyjl.policy.SPUtils;

public class PrimaryPage extends AppCompatActivity {

    PlaySounds playSounds = new PlaySounds();
    Button btnMarket,btnCatlog;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_primary_page);
        btnMarket = findViewById(R.id.btnMarket);
        btnCatlog = findViewById(R.id.btnCatlog);

        playSounds.initSound(this);

        initAppRuler();
        btnMarket.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                playSounds.playSound1();
                Intent i = new Intent(PrimaryPage.this, Market.class);
                startActivity(i);
            }
        });
        btnCatlog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                playSounds.playSound1();
                Intent i = new Intent(PrimaryPage.this, Catalog.class);
                startActivity(i);
            }
        });
    }

    private void initAppRuler(){
        if (!SPUtils.getInstance().getBoolean("has_show_private", false)) {
            Policy.getInstance().showRuleDialog(this, "用户协议和隐私政策概要", this.getString(R.string.ts_private), R.color.link, new Policy.RuleListener() {
                @Override
                public void rule(boolean agree) {
                }

                @Override
                public void oneClick() {
//                    ARouterUtil.go(ARouterUtil.Constant.My.PrivateActivity).navigation();
                    Intent i = new Intent(PrimaryPage.this, com.atguigu.acyjl.activity.PrivateActivity.class);

                    startActivity(i);
                }

                @Override
                public void twoClick() {
//                    ARouterUtil.go(ARouterUtil.Constant.Main.RuleActivity)
//                            .withString("url", "file:////android_asset/userRule.html")
//                            .withBoolean("privateRule", false)
//                            .navigation();
                    Intent i = new Intent(PrimaryPage.this, RuleActivity.class);
                    startActivity(i);
                }
            });
        }
    }




    @Override
    public void onBackPressed() {
        super.onBackPressed();
        finishAffinity(); // 销毁当前应用程序
    }
}
